/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hu.rsc.feeds.client.gui;

import hu.rsc.feeds.client.Feeds;
import hu.rsc.feeds.client.data.Category;
import hu.rsc.feeds.client.data.Feed;

import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HTML;

/**
 * 
 * @author arbuckle
 */
public class FeedDescriptionPopup extends DialogBox {
    public FeedDescriptionPopup(final Feed feed, String dialogtitle) {
	super(true);
	setText(dialogtitle);
	DockPanel main = new DockPanel();
	main.addStyleName("popup");

	HTML description = new HTML();
	StringBuilder html = new StringBuilder("<div>");
	Category c = Feeds.getCategoryById(feed.getCategory());
	if (c != null) {
	    html.append("<h3>" + c.getLabel() + "</h3>");
	}
	html.append((feed.getDescription() != null ? feed.getDescription() : "N/A"));
	html.append("</div>");
	description.setHTML(html.toString());
	main.add(description, DockPanel.CENTER);

	setWidget(main);
    }
}
